package com.example.wordserver.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.Properties;
import java.util.function.Predicate;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docket(Environment environment)
    {


        //获取项目环境
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .enable(true)//是否开启swagger
                .groupName("lhx") //api分组
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.wordserver.controller"))//基于某一个包去扫描
                .build();
    }
    private ApiInfo apiInfo()
    {
        Contact contact = new Contact("lhx","无","1194733285@qq.com");
        return new ApiInfo("lhx的SwaggerAPI文档",
                "学习Swagger日记",
                "1.0",
                "urn:tos",
                contact, "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
